package com.yuncheng.mcp.service;

import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.ollama.OllamaChatModel;
import org.springframework.ai.tool.ToolCallbackProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @title: AiChatService
 * @Author: Liuxk
 * @Date: 2025/5/22 15:14
 */

@Service
public class AiChatService {


    @Autowired
    private OllamaChatModel ollamaChatModel;

    @Autowired
    private ToolCallbackProvider toolCallbackProvider;


    public String ask(String question) {
        ChatClient chatClient = ChatClient.builder(ollamaChatModel)
                .defaultTools(toolCallbackProvider.getToolCallbacks())
                .build();
        String content = chatClient.prompt().user(question).call().content();
        return content;
    }


}
